$(function(){
//	alert(2);
	$(".new_site").click(function(){
			$("#new_add").slideDown(300);
	});
	$("#add_cancel").click(function(){
			$("#new_add").slideUp(500);
	});

})
var showcity;
var showarea;
var infomsg=null;
$(function(){

//	向页面发送ajax
	$.ajax({
		type:"get",
		url:"Public/Home/js/ChinaArea.xml",
		dataType:"xml",
		success:function(msg){
//			alert(2);
//			alert(msg);
//          console.log($(msg).find('province'));
           infomsg=msg;
        $(msg).find('province').each(function(k,v){
        	var nm=$(this).attr('province');
        	var id=$(this).attr('provinceID');
        	$("#province").append("<option value='"+id+"'>"+nm+"</option>");
        });
		}
	});
//	显示所在城市
	 showcity=function(){
		var pid=$("#province").val();
		var two_pid=pid.substr(0,2);
//		console.log($(infomsg).find("City[CityID]"));
        $("#city").empty();
		($(infomsg).find("City[CityID^="+two_pid+"]")).each(function(){
        	var nm=$(this).attr('City');
        	var id=$(this).attr('CityID');
        	$("#city").append("<option value='"+id+"'>"+nm+"</option>");
			
		});
      
	}
//	 显示所在区
	 showarea=function(){
		var cid=$("#city").val();
		var four_cid=cid.substr(0,4);
//		console.log($(infomsg).find("City[CityID]"));
        $("#area").empty();
		($(infomsg).find("Piecearea[PieceareaID^="+four_cid+"]")).each(function(){
        	var nm=$(this).attr('Piecearea');
        	var id=$(this).attr('PieceareaID');
        	$("#area").append("<option value='"+id+"'>"+nm+"</option>");
			
		});
      
	}
//  site_controll页面
    
})
//收货地址
$(function(){
//  收货地址
	var validate = {
		code : false,
		address : false,
		peo : false,
		phone : false
	}
	$('.info_code').blur(function(){
		if($.trim($(this).val()) == ''){
			$('#code_warn').css({'display':'inline-block'});
			validate.code = false;
		}else{
			$('#code_warn').css({'display':'none'});
			validate.code = true;
		}
	});
	$('.info_address').blur(function(){
		if($.trim($(this).val()) == ''){
			$('#address_warn').css({'display':'inline-block'});
			validate.code = false;
		}else{
			$('#address_warn').css({'display':'none'});
			validate.code = true;
		}
	});
		$('.info_peo').blur(function(){
		if($.trim($(this).val()) == ''){
			$('#peo_warn').css({'display':'inline-block'});
			validate.code = false;
		}else{
			$('#peo_warn').css({'display':'none'});
			validate.code = true;
		}
	});
		$('.info_phone').blur(function(){
		if($.trim($(this).val()) == ''){
			$('#phone_warn').css({'display':'inline-block'});
			validate.code = false;
		}else{
			$('#phone_warn').css({'display':'none'});
			validate.code = true;
		}
	});
})